package com.xueyi.workflow.convert;

import com.xueyi.common.core.web.entity.model.BaseConverter;
import com.xueyi.workflow.domain.query.FormDataQuery;
import com.xueyi.workflow.domain.dto.FormDataDto;
import com.xueyi.workflow.domain.entity.FormData;
import com.xueyi.workflow.convert.PageConverterUtil;
import com.github.pagehelper.Page;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

@Component
public class FormDataConverter implements BaseConverter<FormDataQuery, FormDataDto, FormData> {
    @Override
    public FormDataDto mapperDto(FormData po) {
        if (po == null) return null;
        FormDataDto dto = new FormDataDto();
        BeanUtils.copyProperties(po, dto);
        return dto;
    }
    @Override
    public List<FormDataDto> mapperDto(Collection<FormData> poList) {
        if (poList == null) return null;
        return poList.stream().map(this::mapperDto).collect(Collectors.toList());
    }
    @Override
    public Page<FormDataDto> mapperPageDto(Collection<FormData> poList) {
        return PageConverterUtil.mapperPageDto(poList, this::mapperDto);
    }
    @Override
    public FormData mapperPo(FormDataDto dto) {
        if (dto == null) return null;
        FormData po = new FormData();
        BeanUtils.copyProperties(dto, po);
        return po;
    }
    @Override
    public List<FormData> mapperPo(Collection<FormDataDto> dtoList) {
        if (dtoList == null) return null;
        return dtoList.stream().map(this::mapperPo).collect(Collectors.toList());
    }
    @Override
    public Page<FormData> mapperPagePo(Collection<FormDataDto> dtoList) {
        return PageConverterUtil.mapperPagePo(dtoList, this::mapperPo);
    }
} 